package com.example.demo.common.smt;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池枚举
 *
 * @author tangsq
 * @date 2023/05/16
 */
public enum ThreadPoolEnum {

    /**
     * 获取<=time最近一组值线程池 当线程池已满时，新的任务会由提交该任务的线程来执行
     */
    LIST_VALUE_LE_TIME_EXECUTOR_SERVICE(new ThreadPoolExecutor(16, 64, 1L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(64), new ThreadPoolExecutor.CallerRunsPolicy()));


    private ExecutorService threadPoolExecutor;

    ThreadPoolEnum(ThreadPoolExecutor threadPoolExecutor) {
        this.threadPoolExecutor = threadPoolExecutor;
    }

    public ExecutorService getThreadPoolExecutor() {
        return this.threadPoolExecutor;
    }
}
